<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鼠标的坐标？</title>
</head>

<body>
    <p onmousedown="show_coords(event)">点击这一行。一个消息框会提示出鼠标指针的 x 和 y 坐标。</p>
    <script>
        function show_coords(event) {
            var x = event.clientX;
            var y = event.clientY;
            alert("X coords: " + x + ", Y coords: " + y);
        }
    </script>
</body>

</html>